package cate.common.table.item.staruptask;

import cate.common.table.EExcelNoteField;
import cate.common.table.EExcelRowClass;
import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import org.apache.commons.lang3.StringUtils;

import java.util.*;

public class HeroStarTaskRow extends ERow {
    public String cost0;
    public String cost1;
    public String costProp;
    public String specialPropStr;
    public String monsterStr;
    public String rewardStr;
    public String stableStr;
    public String growStr;
    public int levelBreakValue;
    public String skillStr;
    public int preTaskId;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("任务ID", 0);
        this.cost0 = xrw.getString("消耗指定英雄", "");
        this.cost1 = xrw.getString("消耗狗粮", "");
        this.costProp = xrw.getString("消耗道具", "");
        this.specialPropStr = xrw.getString("消耗特殊道具", "");
        this.monsterStr = xrw.getString("渡劫关卡", "");
        this.rewardStr = xrw.getString("渡劫奖励", "");
        this.stableStr = xrw.getString("获得固定属性", "");
        this.growStr = xrw.getString("获得加成属性", "");
        this.levelBreakValue = xrw.getInteger("解锁英雄等级上限", 0);
        this.skillStr = xrw.getString("解锁技能", "");
        this.preTaskId = xrw.getInteger("前置任务",-1);
    }

    /**
     * 技能们
     */
    public List<Integer> skillList;

    public String cost = "";

    public Map<Integer, Double> growMap = new HashMap<>();

    @Override
    public void decode() {
        skillList = new ArrayList<>();
        if (StringUtils.isNotBlank(skillStr)) {
            for (String s : skillStr.split("#")) {
                skillList.add(Integer.valueOf(s));
            }
        }

        if (!StringUtils.isBlank(cost0) && !"0".equals(cost0)) {
            cost += cost0;
        }
        if (!StringUtils.isBlank(cost1) && !"0".equals(cost1)) {
            cost += "#" + cost1;
        }
        if (!StringUtils.isBlank(specialPropStr) && !"0".equals(specialPropStr)) {
            cost += "#" + specialPropStr;
        }

        if (StringUtils.isNotBlank(growStr)) {
            for (String str : growStr.split("#")) {
                String[] arr = str.split(":");
                growMap.put(Integer.parseInt(arr[0]), Integer.parseInt(arr[1]) / 100000d);
            }
        }

    }
}
